<?php
include('common/constants.php');
include('common/db.php');

if (!isset( $_GET )){
	echo "Nothing to save.";
}

//create array to temporarily grab variables
$input_arr = array();
//grabs the $_GET variables and adds slashes
foreach ($_GET as $key => $input_arr) {
	$_GET[$key] = addslashes(htmlspecialchars($input_arr));
}

$slctSql = " SELECT `travel_route` FROM `advertisement` WHERE advert_id='". $_GET['advert_id'] . "'; ";
$result = mysql_query($slctSql) or trigger_error(mysql_error());
$num = mysql_num_rows($result);

if ($num != 0) {	

	$updateSql = "UPDATE `advertisement` SET `travel_route`='".$_GET['mergedRoute']."' WHERE `advert_id` = '". $_GET['advert_id']. "'";
	if(mysql_query($updateSql)){
			echo "success";
	}else{
		echo "fail";
	}

}